package manager;

import org.json.JSONObject;
import entity.qrcode.Action_info;
import entity.qrcode.QrCode;
import entity.qrcode.Scene;
import service.AccessTokenTest;
import service.WxServiceImpl;
import util.Request;

import java.io.InputStream;
import java.util.Map;

public class CreateQrCode {
    static InputStream in= CreateQrCode.class.getClassLoader().getResourceAsStream("wx-config.xml");
    static Map<String,String> Xmlmap= WxServiceImpl.parseRequest(in);
    static final String QRCODE_URL=Xmlmap.get("qrcodeUrl");
    static final String TICKET=Xmlmap.get("ticket");
    static final String GET_CODE_URL=Xmlmap.get("getCodeUrl");

    public static void main(String[] args) {
        String url=QRCODE_URL.replace("TOKEN", AccessTokenTest.getAccessToken());
        Scene scene=new Scene("1");
        Action_info action_info=new Action_info(scene);
        QrCode qrCode=new QrCode("QR_LIMIT_STR_SCENE",action_info);
        JSONObject jsonObject=new JSONObject(qrCode);
        String result= Request.sendPost(url,jsonObject.toString());
        System.out.println(result);
    }

    public static String getCodeUrl(){
        return GET_CODE_URL.replace("TICKET",TICKET);
    }


}
